import request from "@/utils/request.js";


/**
 * 获取资源列表
 * @param queryParams
 * @returns {*}
 */
export function listResource(queryParams) {
    return request({
        url: '/resource',
        method: "GET",
        params: queryParams
    })
}


/**
 * 校验MD5值
 * @param md5
 * @param resourceTypeId
 * @param courseTypeId
 * @returns {*}
 */
export function checkChunk(md5, resourceTypeId, courseTypeId) {
    return request({
        url: `/resource/checkfile/${resourceTypeId}/${courseTypeId}/${md5}`,
        method: "GET"
    })
}

/**
 * 获取资源详情
 * @param id
 * @returns {*}
 */
export function resourceInfo(id) {
    return request({
        url: `/resource/${id}`,
        method: "GET"
    })
}

/**
 * 修改资源信息
 * @param data
 * @returns {*}
 */
export function updateResourceInfo(data) {
    return request({
        url: '/resource',
        method: "PUT",
        data: data
    })
}

/**
 * 删除
 * @param id
 * @returns {*}
 */
export function removeById(id) {
    return request({
        url: `/resource/${id}`,
        method: "DELETE"
    })
}

/**
 * 批量删除
 * @param ids
 * @returns {*}
 */
export function removeByIds(ids) {
    return request({
        url: "/resource/remove/ids",
        method: "DELETE",
        data: ids
    })
}

/**
 * 上传文件切片
 * @param data
 * @returns {*}
 */
export function uploudChunkFile(data) {
    return request({
        url: '/resource/chunk/uploud',
        method: 'POST',
        data: data,
        headers: {
            chunkUploud: true
        }
    })
}

/**
 * 下载资源
 * @returns {*}
 * @param downLoadParams
 */
export function downloadResource(fileName) {
    return request({
        url: `/resource/download?resource=${fileName}`,
        method: "GET",
    })
}